/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Separate_Chat;

import java.util.*;
/**
 *
 * @author Wei Liang
 */

public class IpChat_Main {

    private static ArrayList<Hashtable> AL_HT = new ArrayList<Hashtable>(0);
    public static GUI gui = new GUI();
    public IpChat_Constructor callChat=null;

    public static String newIn=null;
    public static Boolean has_new_text=false;

    //constructor
      public IpChat_Main()
      {
            gui.setVisible(true);
            gui.setchatH();
            callChat= new IpChat_Constructor(AL_HT, this);
      }

       public void update_HashTableArray(ArrayList<Hashtable> new_HT_Array )
        {
            callChat.update_ht(new_HT_Array);
        }





    //<editor-fold desc="Methods">
     public static void sendT(String msgT)
     {   
        String temp = "T" + msgT;
        newIn=temp;
        has_new_text=true;
        System.out.flush();
        //callChat.clients[0].newtext(temp);

        System.out.println("@Call_Main. IpChat_Constructor.clientCount= "+ IpChat_Constructor.clientCount);
       // System.out.println("@Call_Main. callChat.port= "+ IpChat_Constructor.port);
        System.out.println("@Call_Main Message to send is: "+temp);
       System.out.println("@Call_Main. IpChat_Constructor.clients[0].clientname= "+IpChat_Constructor.clients[0].clientname);
        if(IpChat_Constructor.clientCount>0)
            for (int i=0;i <  IpChat_Constructor.clientCount ; i++)
                if(IpChat_Constructor.clients[i].Team.equals(ChatServer.ownTeamNumber) )
                    IpChat_Constructor.clients[i].newtext(temp);
          
     }


    public static void sendA(String msgA)
    {
        String temp = "A" + msgA;
        newIn=temp;
        has_new_text=true;


        System.out.println("@Call_Main. IpChat_Constructor.clientCount= "+ IpChat_Constructor.clientCount);
       // System.out.println("@Call_Main. callChat.port= "+ IpChat_Constructor.port);
        System.out.println("@Call_Main Message to send is: "+temp);
       System.out.println("@Call_Main. IpChat_Constructor.clients[0].clientname= "+IpChat_Constructor.clients[0].clientname);
        if(IpChat_Constructor.clientCount>0)
            for (int i=0;i <  IpChat_Constructor.clientCount ; i++)
                IpChat_Constructor.clients[i].newtext(temp);

        
    }//</editor-fold>





}
